<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hilaver.dzmis.Constants"%>
<%@ page import="com.hilaver.dzmis.service.impl.CtServiceImpl"%>
<%@ page import="com.hilaver.dzmis.service.impl.ProcurementServiceImpl"%>
<%@ page import="com.hilaver.dzmis.service.impl.I18nServiceImpl"%>
<%@ page import="com.hilaver.dzmis.codetable.CtCollarType"%>
<%@ page import="com.hilaver.dzmis.codetable.CtMaterialType"%>
<%@ page import="com.hilaver.dzmis.procurement.Procurement"%>
<%@ page import="com.hilaver.dzmis.product.ProductIdentification"%>
<%@ page import="com.hilaver.dzmis.product.ProductAccessoryZip"%>
<%@ page import="com.hilaver.dzmis.web.servlet.AbstractBaseServlet" %>
<%
	Integer id = Integer.parseInt(request.getParameter("id"));
	CtServiceImpl cs = new CtServiceImpl();
	ProcurementServiceImpl ps = new ProcurementServiceImpl();
	I18nServiceImpl i18n = new I18nServiceImpl();
	Locale locale = (Locale) request.getSession().getAttribute(
			Constants.SESSION_LOCALE);
	ps.setLocale(locale);
	ps.setRealFileDir(AbstractBaseServlet.UPLOAD_TEMP_REAL_DIR);
	Procurement procurement = ps.getObj(id);
	Set<ProductIdentification> piSet = procurement
			.getProductIndentifications();
	Map<String, List<ProductAccessoryZip>> classifiedZipMap = ps.getClassifyZipByCollarType(piSet);
	Set<String> collarKeySet = classifiedZipMap.keySet();
	int columnSpan = 0;
	for(String key : collarKeySet){
		columnSpan += classifiedZipMap.get(key).size();
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.hilaver.dzmis.product.ProductAccessoryButton;"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
<link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
<title><%=procurement.getName()%>--<%=i18n.getShortMessage(locale, "ui.procurement.zip") %></title>
</head>
<body>
<table cellspacing="0" id="the-table" style="width: 100%;">
	<tr>
		<td style="background:#eeeeee;text-align: center;" colspan="<%=columnSpan + 1 %>"><b><%=procurement.getName() %>&nbsp;&nbsp;<%=i18n.getShortMessage(locale, "ui.procurement.zip") %></b></td>
	</tr>
	<tr>
		<td style="width: 120px; text-align: center;">
			<b><%=i18n.getShortMessage(locale, "message.edit.collar") %></b>
		</td>
		<%for(String collarType: collarKeySet){ %>
			<td style="text-align: center;" colspan="<%=classifiedZipMap.get(collarType).size() %>">
				<b><%=cs.getDescription(CtCollarType.class.getName(), collarType, locale) %></b>
			</td>
		<%} %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.reference") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<b><%=paz.getBiAccessoryZip().getReference() %></b>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.colornumber") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getBiAccessoryZip().getColorNumber() %>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "message.edit.materialtype") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=cs.getDescription(CtMaterialType.class.getName(), paz.getBiAccessoryZip().getCtMaterialType(), locale) %>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.teethcolor") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getBiAccessoryZip().getTeethColor() %>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.measure") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getBiAccessoryZip().getMeasure()%>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.length") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getBiAccessoryZip().getZipLength()%>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.blockphoto") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<img width="75px" src="../../_temp/<%=paz.getBiAccessoryZip().getBlockPhotoName() %>"/>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.blockcolor") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getBiAccessoryZip().getBlockColor() %>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.headphoto") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<img width="75px" src="../../_temp/<%=paz.getBiAccessoryZip().getHeadPhotoName() %>"/>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "ui.accessoryzip.headcolor") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getBiAccessoryZip().getHeadColor() %>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "message.order.amount") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getTotal() %>
			</td>
		<%	}
		  } %>
	</tr>
	<tr>
		<td style="text-align: center;">
			<b><%=i18n.getShortMessage(locale, "message.edit.comment") %></b>
		</td>
		<%for(String collarType: collarKeySet){ 
			List<ProductAccessoryZip> zipList = classifiedZipMap.get(collarType);
			for(ProductAccessoryZip paz : zipList){
		%>
			<td style="text-align: center;">
				<%=paz.getComment() %>
			</td>
		<%	}
		  } %>
	</tr>
</table>
</body>
</html>